<%@ page import="com.goal98.team.Constants; com.goal98.team.domain.Position" %>
<head>
  <meta name="layout" content="main"/>
  <title><g:message code="player.edit" default="Edit Player"/></title>
</head>

<body>

  <div class="nav">
    %{--<span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>--}%
    <span class="menuButton"><g:link class="list" controller="player" action="list"><g:message code="player.list" default="Player List"/></g:link></span>
    <g:ifAnyGranted role="${Constants.ROLE_ADMIN + ',' + Constants.ROLE_TEAM_ADMIN}">
      <span class="menuButton"><g:link class="create" controller="player" action="create"><g:message code="player.create" default="New Player"/></g:link></span>
    </g:ifAnyGranted>
  </div>

  <div class="body">
    <h1><g:message code="player.edit" default="Edit Player"/></h1>
    <g:if test="${flash.message}">
      <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${person}">
      <div class="errors">
        <g:renderErrors bean="${person}" as="list"/>
      </div>
    </g:hasErrors>

  %{--<div class="prop">
    <span class="name">ID:</span>
    <span class="value">${person.id}</span>
  </div>--}%

    <g:form>
      <input type="hidden" name="id" value="${person.id}"/>
      <input type="hidden" name="version" value="${person.version}"/>
      <div class="dialog">
        <table>
          <tbody>

            <tr class="prop">
              <td valign="top" class="name"><label for="username"><g:message code="register.id" default="Login Name"/><common:mandatory/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'username', 'errors')}">
                <input type="text" id="username" name="username" value="${person.username?.encodeAsHTML()}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name"><label for="userRealName"><g:message code="register.fullName" default="Full Name"/><common:mandatory/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'userRealName', 'errors')}">
                <input type="text" id="userRealName" name="userRealName" value="${person.userRealName?.encodeAsHTML()}"/>
              </td>
            </tr>

            %{--<tr class="prop">
              <td valign="top" class="name"><label for="passwd">Password:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'passwd', 'errors')}">
                <input type="password" id="passwd" name="passwd" value="${person.passwd?.encodeAsHTML()}"/>
              </td>
            </tr>--}%

            %{--<tr class="prop">
              <td valign="top" class="name"><label for="enabled">Enabled:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'enabled', 'errors')}">
                <g:checkBox name="enabled" value="${person.enabled}"/>
              </td>
            </tr>--}%

            <tr class="prop">
              <td valign="top" class="name"><label for="description"><g:message code="player.desc" default="Remark"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'description', 'errors')}">
                <input type="text" id="description" name="description" value="${person.description?.encodeAsHTML()}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name"><label for="position.id"><g:message code="player.position" default="Position"/>:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'position', 'errors')}">
                <g:select from="${Position.list()}" name="position.id" optionKey="id" value="${person.position?.id}"/>
              </td>
            </tr>

            %{--<tr class="prop">
              <td valign="top" class="name"><label for="email">Email:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'email', 'errors')}">
                <input type="text" id="email" name="email" value="${person?.email?.encodeAsHTML()}"/>
              </td>
            </tr>--}%

            %{--<tr class="prop">
              <td valign="top" class="name"><label for="emailShow">Show Email:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'emailShow', 'errors')}">
                <g:checkBox name="emailShow" value="${person.emailShow}"/>
              </td>
            </tr>--}%

            %{--<tr class="prop">
              <td valign="top" class="name"><label for="authorities">Roles:</label></td>
              <td valign="top" class="value ${hasErrors(bean: person, field: 'authorities', 'errors')}">
                <ul>
                  <g:each var="entry" in="${roleMap}">
                    <li>${entry.key.authority.encodeAsHTML()}
                    <g:checkBox name="${entry.key.authority}" value="${entry.value}"/>
                    </li>
                  </g:each>
                </ul>
              </td>
            </tr>--}%

          </tbody>
        </table>
      </div>

      <div class="buttons">
        <span class="button"><g:actionSubmit class="save" controller="player" value="${message(code:'button.update', 'default':'Update')}" action="update"/></span>
        <span class="button"><g:actionSubmit class="delete" controller="player" onclick="return confirm('Are you sure?');" value="Delete"/></span>
      </div>

    </g:form>

  </div>
</body>
